package com.lagou.service;

import com.lagou.config.Config;
import com.lagou.pojo.Resume;

import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.ArrayList;

public class ResumeService {
    public Resume selectOne() {
        try {
            PreparedStatement preparedStatement = Config.getDataSource().getConnection().prepareStatement("select * from tb_resume limit 1");
            ResultSet resultSet = preparedStatement.executeQuery();


            ArrayList<Resume> objects = new ArrayList<>();

            // 6. 封装返回结果集
            while (resultSet.next()){
                Resume resume = new Resume();
                //元数据
                resume.setId(resultSet.getLong(1));
                resume.setName(resultSet.getString(2));
                resume.setAddress(resultSet.getString(3));
                resume.setAddress(resultSet.getString(4));

                objects.add(resume);

            }
            return objects.get(0);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
